package com.ferry.protocol;

/**
 * Created by daiyong
 * 协议头长度 16
 * 2bytes:magic
 * 1byte:messageType
 * 1byte:serializerType
 * 1byte:请求响应状态码
 * 8byte:请求id
 * 4byte:消息体长度
 * 共17字节
 */
public class ProtocolHeader {

	public static final int HEADER_SIZE = 16;

	public static final short MAGIC = (short) 0xedba;     //圣特尔科技

	/**
	 * 消息类型
	 */
	private byte messageType;
	/**
	 * 序列化类型
	 */
	private byte serializerType;

	private byte statusCode;            // 请求响应状态码
	private long id;                // request.invokeId,
	private int bodySize;           // 消息体长度

	public byte messageType() {
		return messageType;
	}

	public void messageType(byte messageType) {
		this.messageType = messageType;
	}

	public byte serializerType() {
		return serializerType;
	}

	public void serializerType(byte serializerType) {
		this.serializerType = serializerType;
	}

	public byte statusCode() {
		return statusCode;
	}

	public void statusCode(byte statusCode) {
		this.statusCode = statusCode;
	}

	public long id() {
		return id;
	}

	public void id(long id) {
		this.id = id;
	}

	public int bodySize() {
		return bodySize;
	}

	public void bodySize(int bodyLength) {
		this.bodySize = bodyLength;
	}

	@Override
	public String toString() {
		return "ProtocolHeader{" +
				"messageType=" + messageType +
				", serializerType=" + serializerType +
				", statusCode=" + statusCode +
				", id=" + id +
				", bodySize=" + bodySize +
				'}';
	}
}
